<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
</head>
<body>
    <h1 align="center" style="color:red">首页</h1>

<!--  以下两行代码二选一，未登录显示跳转，登录显示 你好  -->
<!--    通过name是否有值来判断是否登录-->
    {% if  name %}
<!--    如果name有值，说明登录过，判断为true-->
    <p>
        <a href="/loginout/">你好！{{name}}</a>
    </p>
    {% else %}
<!--    如果name无值，说明没登录，判断为false-->
    <a href="/login">跳转到登陆页面</a>
    {% endif %}

<!--
    <table>
        <thead>
            <tr>
                <th>学生成绩</th>
                <th>成绩等级</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>{{stuname}}</td>
                <td>
                    {% if score >= 90 %}
                    <td>A</td>
                    {% elif score >= 80 %}
                    <td>B</td>
                    {% elif score >= 70 %}
                    <td>C</td>
                    {% elif score >= 60 %}
                    <td>D</td>
                    {% else %}
                    <td>E</td>
                    {% endif %}
                </td>
            </tr>

        </tbody>
    </table>
-->
    <div>
        <form action="/index/" method="get">
                <input type="text" placeholder="搜索框" name="keywords">
                <input type="submit" >
        </form>
    </div>

    <div>
        <a href="/goshopping/">我的购物车</a>

    </div>

    <table>
        <thead>
            <tr>
                <th>商品序号</th>
                <th>商品名称</th>
                <th>商品图片</th>
                <th>商品价格</th>
                <th>商品数量</th>
            </tr>
        </thead>
        <tbody>
            {% for good in goods %}
            <tr>
                <th>{{good.gid}}</th>
                <th>
                    <a href="/goodinfo/?gid={{good.gid}}">{{good.name}}</a>
                </th>
                <th>
                    <img src={{good.imgsrc}} weight="100" height="100">
                </th>
                <th>{{good.price}}</th>
                <th>{{good.count}}</th>
            </tr>
            {% endfor %}
        </tbody>

        <tfoot>
            <tr>
                <th colspan="5">    <!-- 合并单元格 5个 -->
                    {% for item in pagelist %}
                    {% if name %}
                    <a href="/index/?page={{item}}&name={{name}}">{{item}}</a>
                    {% else  %}
                    <a href="/index/?page={{item}}">{{item}}</a>
                    {% endif %}
                    {% endfor %}
                </th>
            </tr>
        </tfoot>
    </table>
</body>
</html>